<% content_for :doc_title, t('intro.admin.tour_list') %>
<% content_for :box_class, 'intro-admin__box-tours' %>
<% content_for :box_title, t('intro.admin.tour_list') %>
<% content_for :box_actions do %>
  <%= link_to t('intro.admin.add_tour'), new_admin_tour_path %>
<% end%>

<%= render layout: 'intro/admin/tours/container' do %>
  <% if @tours.blank? %>
    <div class='message'>
      <%= t('intro.admin.none_tours') %>
    </div>
  <% else %>
    <table class='intro-admin__tours-table'>
      <thead>
        <tr>
          <th>ID</th>
          <th><%= t('intro.admin.tour.ident') %></th>
          <th><%= t('intro.admin.tour.simple_route') %></th>
          <th><%= t('intro.admin.tour.created_time') %></th>
          <th><%= t('intro.admin.tour.expired_time') %></th>
          <th><%= t('intro.admin.actions') %></th>
        </tr>
      </thead>
      <tbody>
        <% @tours.each do |tour| %>
          <tr class="intro-admin__tours-item <%= 'expired' if tour.expired? %>">
            <td><%= tour.id %></td>
            <td class='ident-column' title="<%= tour.ident %>"><%= tour.ident %></td>
            <td class='simple-route-column' title="<%= tour.simple_route %>"><%= tour.simple_route %></td>
            <td><%= tour.created_at.strftime('%F') %></td>
            <td><%= tour.expired_at.try(:strftime, '%F') %></td>
            <td>
              <%= link_to t('intro.admin.edit'), edit_admin_tour_path(tour) %>
              <%= link_to (tour.published? ? t('intro.admin.unpublish') : t('intro.admin.publish')), publish_admin_tour_path(tour, published: !tour.published), method: :put %>
              <%= link_to t('intro.admin.delete'), admin_tour_path(tour), method: :delete, data: { confirm: t('intro.admin.tips.delete_tour_confirm') } %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <center class='intro-admin__pagination'>
      <%= paginate @tours %>
    </center>
  <% end %>
<% end %>